<template>
<div class="contain">
  <div class="loader-base" v-if="showLoad"><div class="loader-wrap"></div></div>
  <header class="hd-top">
    <span class="iconfont icon-left" @click="goBack"></span>
    <h2 class="title">在线下单</h2>
    <button class="btn" @click="submit()">提交</button>
  </header>
  <div class="page">
    <div class="form-line2 displayflex mb0 lineb" @click="address(1)">
      <div class="left green">发</div>
      <dl class="ctx flex1">
        <dt v-if="FHAddress.length==0" >发货地址</dt>
        <dt v-else>{{FHAddress.Province | province}}{{FHAddress.City | city}}{{FHAddress.District | district}}{{FHAddress.Address}}
          <div style="display:none" id="DepartureVenue">{{FHAddress.Province | province}}/{{FHAddress.City | city}}/{{FHAddress.District | district}}</div>
        </dt>
        <dd v-if="FHAddress.length==0" >请选择</dd>
        <dd v-else>{{FHAddress.Contacts}}   {{FHAddress.ContactsTel}}</dd>
      </dl>
      <i class="iconfont icon-right" v-if="$route.query.Billtype!=2"></i>
    </div>
    <div class="form-line2 displayflex" :class="{mb0:stationShow,lineb:stationShow}" @click="address(2)">
      <div class="left yellow">收</div>
      <dl class="ctx flex1">
        <dt v-if="SHAddress.length==0" >收货地址</dt>
        <dt  v-else>{{SHAddress.Province | province}}{{SHAddress.City | city}}{{SHAddress.District | district}}{{SHAddress.Address}}
          <div style="display:none" id="ArrivalVenue">{{SHAddress.Province | province}}/{{SHAddress.City | city}}/{{SHAddress.District | district}}</div>
        </dt>
        <dd v-if="SHAddress.length==0" >请选择</dd>
        <dd v-else>{{SHAddress.Contacts}}   {{SHAddress.ContactsTel}}</dd>
      </dl>
      <i class="iconfont icon-right" v-if="$route.query.Billtype!=2"></i>
    </div>
    <div class="form-switch" :class="{mb0:stationValue,lineb:stationValue}" v-if="stationShow">
      <x-switch title="客运站中转" v-model="stationValue" prevent-default></x-switch>
    </div>
    <template v-if="stationValue">
      <div class="form-box displayflex mb0 lineb trans-line" @click="transaddress">
        <div class="label">中转交货地址</div>
        <div class="ctx flex1 txt-rit">
          <div v-if="ZZAddress.length==0" >请选择</div>
          <div v-else>{{ZZAddress.Province | province}}{{ZZAddress.City | city}}{{ZZAddress.District | district}}{{ZZAddress.Address}}
            <div style="display:none" id="StartBusTerminal">{{ZZAddress.Province | province}}/{{ZZAddress.City | city}}/{{ZZAddress.District | district}}/{{ZZAddress.Address}}</div>
          </div>
        </div>
        <i class="iconfont icon-right"></i>
      </div>
      <!-- <div class="form-line2 displayflex" @click="transaddress">
        <div class="left gray">转</div>
        <dl class="ctx flex1">
          <dt v-if="ZZAddress.length==0" >请选择中转交货地址</dt>
          <dt v-else>{{ZZAddress.Province | province}}{{ZZAddress.City | city}}{{ZZAddress.District | district}}{{ZZAddress.Address}}
            <div style="display:none" id="StartBusTerminal">{{ZZAddress.Province | province}}/{{ZZAddress.City | city}}/{{ZZAddress.District | district}}/{{ZZAddress.Address}}</div>
          </dt>
        </dl>
        <i class="iconfont icon-right" v-if="$route.query.Billtype!=2"></i>
      </div> -->
      <div class="displayflex form-box">
        <x-address class="address-wrap" title="购票目的地" v-model="stationAddressValue" :list="addressData" placeholder="请选择" value-text-align="right">
        </x-address>
        <div style="display:none" id="EndBusTerminal">{{stationAddressValue[0] | province}}/{{stationAddressValue[1] | city}}/{{stationAddressValue[2] | district}}</div>
        <i class="iconfont icon-right"></i>
      </div>
      <div class="mb20 ft14 gray plr20">配送员将在要求到达时间前将货物送达中转交货地址，并按照购票目的地代购长途车票</div>
    </template>
    <!-- <div class="form-box">
      <div class="displayflex" @click="choice">
        <div class="label">商品信息</div>
        <div class="ctx flex1 txt-rit">请选择</div>
        <i class="iconfont icon-right"></i>
      </div>
      <div class="goods-img cf" v-if="goods.length > 0">
        <ul class="cf" v-for="item in goods">
          
            <p>{{item.GoodsName}} {{item.GoodsSpec}}    {{item.PurchaserPoQty}}{{item.MinUnitStyle}}</p>
         
        </ul>
        <div class="tip">共{{OrdersPKGS}}件商品</div>
      </div>
    </div> -->
    <div class="form-switch mb0 lineb">
      <x-switch title="是否加急" v-model="stringValue" prevent-default></x-switch>
    </div>
    <div class="form-wrap2 mb30 mb0 lineb">
      <p class="txt">装箱照片</p>
       <uploader-imgs :word="'凭证'" v-model="picJson" :list="picJson"></uploader-imgs>
    </div>
    <div class="form-box displayflex mb0 lineb">
      <div class="label">提货时间</div>
      <div class="ctx flex1 txt-rit">
        <datetime v-model="valueStart1" 
           format="YYYY-MM-DD HH:mm"
           year-row="{value}年" month-row="{value}月" day-row="{value}日" hour-row="{value}点" minute-row="{value}分"
           :start-date = 'today'>{{valueStart1}}</datetime>
      </div>
      <i class="iconfont icon-right"></i>
    </div>
    <div class="form-box displayflex mb0 lineb">
      <div class="label">要求到达时间</div>
      <div class="ctx flex1 txt-rit">
        <datetime v-model="valueStart2" 
           format="YYYY-MM-DD HH:mm"
           year-row="{value}年" month-row="{value}月" day-row="{value}日" hour-row="{value}点" minute-row="{value}分"
           :start-date = 'today'>{{valueStart2}}</datetime>
      </div>
      <i class="iconfont icon-right"></i>
    </div>
    <div class="form-box displayflex mb0 lineb">
      <div class="label">件数</div>
      <div class="ctx flex1">
        <input type="tel" class="txt-rit" placeholder="请输入" v-model="OrdersPKGS">
      </div>
      <i class="rit">件</i>
    </div>
    <div class="form-box displayflex mb0 lineb">
      <div class="label">重量</div>
      <div class="ctx flex1">
        <input type="number" class="txt-rit" placeholder="必填" 
          v-model="OrdersWeight"
          @keyup="checkNum(OrdersWeight,'重量')" @blur="BlurWeight()">
      </div>
      <i class="rit">kg</i>
    </div>
    <div class="form-box displayflex mb0 lineb">
      <div class="label">体积</div>
      <div class="ctx flex1">
        <input type="number" class="txt-rit" placeholder="必填" 
          v-model="OrdersVolumn"
          @keyup="checkNum(OrdersVolumn,'体积')">
      </div>
      <i class="rit">m³</i>
    </div>
    <div class="form-box displayflex">
      <div class="label">运费</div>
      <div class="ctx flex1 org">
        <div class="txt-rit">{{CarrierAmount}}</div>
      </div>
      <i class="rit org">元</i>
    </div>
    <!-- <div class="form-switch">
      <x-switch title="保险服务" v-model="stringValue" prevent-default @on-click=""></x-switch>
      <div class="server"><i class="iconfont icon-qa"></i></div>
    </div> -->
    <div class="form-remind ft14 gray" @click="showDialogSecure=true;">运费参考价格<i class="iconfont icon-remind"></i></div>
    <div class="displayflex form-box" @click="secure">
      <div class="label">货运险</div>
      <div class="flex1 txt-rit ft14">
        {{ moneyNum || InsuranceInstruct }}
      </div>
      <i class="iconfont icon-right"></i>
    </div>
    <div class="form-remind ft14 gray" @click="showDialogServer=true;">货运险投保须知<i class="iconfont icon-remind"></i></div>
    <div class="form-box displayflex" @click="showServer=true;">
      <div class="label">增值服务</div>
      <div class="flex1 txt-rit" >非必填</div>
      <i class="iconfont icon-right"></i>
    </div>
    <div class="form-box displayflex mb0">
      <div class="label">备注</div>
      <div class="ctx flex1">
        <x-textarea title="" placeholder="非必填" v-model="Memo" autosize :max="200"></x-textarea>
        <!-- <textarea placeholder="请输入" v-model="Memo"></textarea> -->
      </div>
    </div>
    <div class="remark-wrap cf">
      <p class="tit">快捷标签选择</p>
      <template v-for="item in remarkCheck">
        <label class="remark-check f-l">
          <input type="checkbox" class="ipt" name="remark" v-model="remarkValue" :value="item.text">
          <span class="txt">{{item.text}}</span>
        </label>
      </template>
    </div>
  </div>
  <div class="btn-double displayflex" v-if="type!='2'">
    <div class="flex1" v-if="btnshow==true" @click="getBalance('11')">保存</div>
    <div class="flex1" v-if="btnshow==true" @click="getBalance('12')">发单</div>
    <div class="flex1" v-if="btnshow==false" @click="getBalance('1')">保存</div>
  </div>
  <div class="btn-double displayflex" v-if="type=='2'">
    <div class="flex1" @click="getBalance('12')">发单</div>
  </div>
  <!-- 增值服务 start -->
  <popup v-model="showServer">
    <div class="pop-server">
      <div class="title ft17">增值服务</div>
      <ul class="list ft14">
        <li>
          <label class="displayflex checkbox-wrap">
            <input type="checkbox" disabled>
            <i class="iconfont icon-uncheck"></i>
            <i class="iconfont icon-checkbox"></i>
            <em class="flex1">代消毒</em>
            <em>￥100</em>
          </label>
        </li>
        <li>
          <label class="displayflex checkbox-wrap">
            <input type="checkbox" disabled>
            <i class="iconfont icon-uncheck"></i>
            <i class="iconfont icon-checkbox"></i>
            <em class="flex1">代跟台</em>
            <em>￥400</em>
          </label>
        </li>
      </ul>
      <div class="ser-btn ft17" @click="showServer=false;">服务暂未开放，<em class="blue">知道了</em></div>
    </div>
  </popup>
  <!-- 增值服务 end -->
  <!-- 货运险start -->
  <popup v-model="showSecure">
    <div class="pop-server">
      <div class="title ft17">货运险</div>
      <div class="box">
        <div class="secure-box displayflex">
          <div class="flex1">货运险保额</div>
          <div class="secure-ipt">
            <x-number v-model="secureValue" :value="GiveInsuranceFee" :min="secureMin"></x-number>
          </div>
          <span>万元</span>
        </div>
        <div class="tip org">费用：￥{{secureFee}}</div>
      </div>
      <div class="ser-btn ft17" @click="saveSecure"><em class="blue">确定</em></div>
    </div>
  </popup>
  <!-- 货运险end -->
  <!-- 运费参考价格start -->
  <x-dialog v-model="showDialogSecure" hide-on-blur :dialog-style="{'max-width': '100%', width: '100%', height: '100%', 'background-color': '#fff'}">
    <div class="dialog-secure dialog-s">
      <i class="iconfont icon-close" @click="showDialogSecure=false;"></i>
      <div class="tit">运费标准</div>
      <ul class="list">
        <li><span>5公里以内（含5公里）：</span><em>30元</em></li>
        <li><span>5~10公里（含10公里）：</span><em>50元</em></li>
        <li><span>10公里以上：</span><em>70元</em></li>
      </ul>
      <!-- <p class="tip">此价格仅针对10kg以内货物，超重部分需按照2元/kg叠加续重费用。</p> -->
      <dl>
        <!-- <dt>温馨提醒：</dt> -->
        <dd>此价格仅针对10kg以内货物，超重部分需按照2元/kg叠加续重费用。</dd>
      </dl>
    </div>
  </x-dialog>
  <!-- 运费参考价格end -->
  <!-- 货运险投保须知start -->
  <x-dialog v-model="showDialogServer" hide-on-blur :dialog-style="{'max-width': '100%', width: '100%', height: '100%', 'background-color': '#fff'}">
    <tab :line-width='2'
       class="lltab">
      <tab-item selected @on-item-click="showRule = true;">公路货物运输</tab-item>
      <tab-item  @on-item-click="showRule = false;">附加盗窃、抢劫</tab-item>
    </tab>
    <div class="dialog-server dialog-s" v-if='showRule'>
      <i class="iconfont icon-close" @click="showDialogServer=false;"></i>
      <div class="tit ft17">本公司保险由人保提供服务，具体条款如下：</div>
      <dl class="dialog-dl">
        <h2>公路货物运输保险条款（2009版）</h2>
        <dt>保险标的范围</dt>
        <dd>
          第一条  凡在国内经公路运输的货物均可为本保险之标的。<br/>
          第二条  下列货物非经投保人与保险人特别约定，并在保险单（凭证）上载明，不在保险标的范围以内：金银、珠宝、钻石、玉器、首饰、古币、古玩、古书、古画、邮票、艺术品、稀有金属等珍贵财物。<br/>
          第三条  下列货物不在保险标的范围以内：蔬菜、水果、活牲畜、禽鱼类和其它动物。
        </dd>
        <dt>保险责任</dt>
        <dd>
          第四条 由于下列保险事故造成保险货物的损失和费用，保险人依照本条款约定负责赔偿：<br/>
          （一）火灾、爆炸、雷电、冰雹、暴风、暴雨、洪水、海啸、地陷、崖崩、突发性滑坡、泥石流；<br/>
          （二）由于运输工具发生碰撞、倾覆或隧道、码头坍塌，或在驳运过程中因驳运工具遭受搁浅、触礁、沉没、碰撞；<br/>
          （三）在装货、卸货或转载时因意外事故造成的损失；<br/>
          （四）因碰撞、挤压而造成货物破碎、弯曲、凹瘪、折断、开裂的损失；<br/>
          （五）因包装破裂致使货物散失的损失；<br/>
          （六）液体货物因受碰撞或挤压致使所用容器（包括封口)损坏而渗漏的损失，或用液体保藏的货物因液体渗漏而造成该货物腐烂变质的损失；<br/>
          （七）符合安全运输规定而遭受雨淋所致的损失；<br/>
          （八）在发生上述灾害事故时，因纷乱造成货物的散失以及因施救或保护货物所支付的直接合理的费用。
        </dd>
        <dt>责任免除</dt>
        <dd>
          第五条  由于下列原因造成保险货物的损失，保险人不负赔偿责任：<br/>
         （一）战争、敌对行为、军事行动、扣押、罢工、暴动、哄抢；<br/>
         （二）地震造成的损失；<br/>
         （三）盗窃或整件提货不着的损失；<br/>
         （四）在保险责任开始前，保险货物已存在的品质不良或数量短差所造成的损失；<br/>
         （五）保险货物的自然损耗，本质缺陷、特性所引起的损失或费用；<br/>
         （六）市价跌落、运输延迟所引起的损失；<br/>
         （七）属于发货人责任引起的损失；<br/>
         （八）投保人、被保险人的故意行为或违法犯罪行为。<br/>
          第六条  经国家有关部门认定的违法、非法货物，保险人不负赔偿责任。<br/>
          第七条  其他不属于保险责任范围的损失，保险人不负赔偿责任<br/>
        </dd>
        <dt>责任起讫</dt>
        <dd>
          第八条  保险责任自签发保险凭证后，保险货物运离起运地发货人的最后一个仓库或储存处所时起，至该保险凭证上注明的目的地的收货人在当地的第一个仓库或储存处所时终止。但保险货物运抵目的地后，如果收货人未及时提货，则保险责任的终止期最多延长至保险货物卸离运输工具后的十五天为限。
        </dd>
        <dt>保险价值和保险金额</dt>
        <dd>
          第九条  保险价值为货物的实际价值，按货物的实际价值或货物的实际价值加运杂费确定。保险金额由投保人参照保险价值自行确定，并在保险合同中载明。保险金额不得超过保险价值。超过保险价值的，超过部分无效，保险人应当退还相应的保险费。
        </dd>
        <dt>投保人、被保险人的义务</dt>
        <dd>
          第十条  投保人应当履行如实告知义务，如实回答保险人就保险标的或者被保险人的有关情况提出的询问。<br/>
          投保人故意或因重大过失未履行前款规定的如实告知义务，足以影响保险人决定是否同意承保或者提高保险费率的，保险人有权解除保险合同。 
          投保人故意不履行如实告知义务的，保险人对于保险合同解除前发生的保险事故，不承担赔偿责任，并不退还保险费。
          投保人因重大过失未履行如实告知义务，对保险事故的发生有严重影响的，保险人对于保险合同解除前发生的保险事故，不承担赔偿责任，但应当退还保险费。<br/>
          第十一条  投保人在保险人或其代理人签发保险单（凭证）的同时，应一次交清应付的保险费。若投保人未按照约定交付保险费，保险费交付前发生的保险事故，保险人不承担赔偿责任。<br/>
          第十二条　投保人和被保险人应当严格遵守国家及交通运输部门关于安全运输的各项规定，维护保险标的的安全。货物运输包装必须符合国家和主管部门规定的标准。<br/>
          保险人可以对保险标的的安全状况进行检查，向投保人、被保险人提出消除不安全因素和隐患的书面建议，被保险人应该认真付诸实施。
          对于因被保险人未遵守上述约定而导致保险事故的，保险人不负赔偿责任；对于因被保险人未遵守上述约定而导致损失扩大的，保险人对扩大的损失不负赔偿责任。<br/>
          第十三条　在合同有效期内，保险标的危险程度显著增加的，被保险人按照合同约定应当及时通知保险人，保险人有权要求增加保险费或者解除合同。 <br/>
          被保险人未履行前款规定的通知义务的，因保险标的危险程度显著增加而发生的保险事故，保险人不承担赔偿责任。<br/>
          第十四条  保险货物如果发生保险责任范围内的损失时，投保人或被保险人获悉后，应迅速采取合理的施救和保护措施并立即通知保险人的当地机构（最迟不超过10天）。<br/>
          故意或者因重大过失未及时通知，致使保险事故的性质、原因、损失程度等难以确定的，保险人对无法确定的部分，不承担赔偿责任，但保险人通过其他途径已经及时知道或者应当及时知道保险事故发生的除外。
        </dd>
        <dt>赔偿处理</dt>
        <dd>
          第十五条  被保险人向保险人申请索赔时，必须提供下列有关单证：<br/>
          （一）保险单（凭证）、运单（货票）、提货单、发票（货价证明）；<br/>
          （二）承运部门签发的事故签证、交接验收记录、鉴定书；<br/>
          （三）收货单位的入库记录、检验报告、损失清单及救护保险货物所支付的直接合理的费用单据；<br/>
          （四）被保险人所能提供的其他与确认保险事故的性质、原因、损失程度等有关的证明和资料。<br/>
          保险人收到被保险人的赔偿请求后，应当及时就是否属于保险责任作出核定，并将核定结果通知被保险人。情形复杂的，保险人在收到被保险人的赔偿请求并提供理赔所需资料后三十日内未能核定保险责任的，保险人与被保险人根据实际情形商议合理期间，保险人在所商定的期间内作出核定结果并通知被保险人。对属于保险责任的，在与被保险人达成有关赔偿金额的协议后十日内，履行赔偿义务。<br/>
          第十六条  保险货物发生保险责任范围内的损失时，保险金额等于或高于保险价值时，保险人应根据实际损失计算赔偿，但最高赔偿金额以保险价值为限；保险金额低于保险价值的，保险人对其损失金额及支付的施救保护费用按保险金额与保险价值的比例计算赔偿。保险人对货物损失的赔偿金额，以及因施救或保护货物所支付的直接合理的费用，应分别计算，并各以不超过保险金额为限。<br/>
          第十七条  保险货物发生保险责任范围内的损失，如果根据法律规定或有关约定，应当由承运人或其他第三者负责赔偿部分或全部的，被保险人应首先向承运人或其他第三者提出书面索赔，直至诉讼。保险事故发生后，保险人未赔偿保险金之前，被保险人放弃对有关责任方请求赔偿的权利的，保险人不承担赔偿责任；如被保险人要求保险人先予赔偿，被保险人应签发权益转让书和应将向承运人或第三者提出索赔的诉讼书及有关材料移交给保险人，并协助保险人向责任方追偿。<br/>
          由于被保险人的故意或重大过失致使保险人不能行使代位请求赔偿权利的，保险人可以相应扣减保险赔偿金。<br/>
          第十八条  经双方协商同意，保险人可将其享有的保险财产残余部分的权益作价折归被保险人，并可在保险赔偿金中直接扣除。<br/>
          第十九条  被保险人与保险人发生争议时，协商解决，双方不能达成协议时，可以提交仲裁机关或法院处理。   <br/>
          本保险合同适用中华人民共和国法律(不包括港澳台地区法律）。
        </dd>
        <dt>其他事项</dt>
        <dd>
          第二十条  凡经公路与其他运输方式联合运输的保险货物，按相应的运输方式分别适用本条款及《铁路货物运输保险条款（2009版）》、《水路货物运输保险条款（2009版）》和《国内航空货物运输保险条款（2009版）》。<br/>
          第二十一条  凡涉及本保险的约定均采用书面形式。
        </dd>
      </dl>
    </div>
    <div class="dialog-server dialog-s" v-if='!showRule'>
      <i class="iconfont icon-close" @click="showDialogServer=false;"></i>
      <div class="tit ft17">本公司保险由人保提供服务，具体条款如下：</div>
      <dl class="dialog-dl">
        <h2>公路货物运输保险条款（2009版）</h2>
        <dt>第一条 保险责任</dt>
        <dd>
          保险人对保险货物在保险期间内由于外来的有明显盗窃、抢劫、哄抢痕迹并经公安部门证明确系盗窃、抢劫、哄抢行为以及全车被他人诈骗所致的直接经济损失承担赔偿责任。
        </dd>
        <dt>第二条 责任起迄</dt>
        <dd>
          在保险合同有效期内，每次运输的保险责任起讫期为保险货物自运离保险凭证（保险单）上载明的起运地时起，至运抵保险凭证（保险单）载明的目的地卸离运输工具时止。但保险货物运抵目的地后，如果收货人未及时卸货，则保险责任的终止期从抵达目的地当日零时起计算最多延长48小时。
        </dd>
        <dt>第三条 责任免除</dt>
        <dd>
          下列原因造成保险货物的损失，保险人不负赔偿责任：<br/>
          1.保险货物被政府有关部门征用、罚没、扣押；<br/>
          2.被保险人或驾驶员与他人发生民事纠纷；<br/>
          3. 投保人或被保险人的故意行为、违法犯罪行为；<br/>
          4. 其他不属于保险责任范围的原因。
        </dd>
        <dt>第四条 投保人或被保险人的义务</dt>
        <dd>
          1. 投保人或被保险人获知或应当获知保险货物发生保险责任范围内的损失后，应立即向当地公安部门报案，并同时通知保险人。故意或者因重大过失未及时通知，致使保险事故的性质、原因、损失程度等难以确定的，保险人对无法确定的部分，不承担赔偿责任，但保险人通过其他途径已经及时知道或者应当及时知道保险事故发生的除外。<br/>
          2. 当货物发生损失时，投保人或被保险人应采取积极有效措施制止货物损失进一步扩大，否则保险人就损失扩大部分不负赔偿责任。
        </dd>
        <dt>第五条 赔偿处理</dt>
        <dd>
          1. 被保险人向保险人索赔时，须提供出险地公安部门出具的证明；全车被骗的，须提供出险地县级以上（含县级）公安刑侦部门出具的证明。否则，保险人有权对部分或全部经济损失不负赔偿责任。<br/>
          2. 本附加险责任范围内的盗窃、抢劫、哄抢所造成的保险货物的直接经济损失，在被保险人报案30天后未能侦破，并由被保险人出具盗窃、抢劫、哄抢事故报告、损失清单、公安部门的证明材料及被保险人所能提供的其他与确认保险事故的性质、原因、损失程度等有关的证明和资料后，保险人给予赔偿。全车被骗所致保险货物的直接经济损失，须经县级以上（含县级）公安刑侦部门立案满三个月未能侦破，被保险人出具公安部门的证明材料及保险人认为必要的其他单证后保险人给予赔偿。<br/>
          3. 经公安部门破案被追回的保险货物，双方应当协商处理。<br/>
          4. 保险货物发生保险责任范围内的损失时，赔偿按主险条款赔偿处理的有关规定计算赔偿金额。被盗、被抢货物的赔偿均实行20%的绝对免赔，全车被骗的赔偿实行30%的绝对免赔。
        </dd>
        <dt>第六条 其他事项</dt>
        <dd>
          本条款为《公路货物运输保险条款（2009版）》、《国内货物运输公路定额保险条款（2009版）》的附加条款。本条款与上述条款相抵触之处，以本条款为准，其他未尽事项以主险条款为准。
        </dd>
      </dl>
    </div>
  </x-dialog>
  <!-- 货运险投保须知end -->
</div>
</template>

<script>
import uploaderImgs from "@/components/share/NewUploaders.vue";
export default {
  name: "onlineOrder",
  components: {
    uploaderImgs
  },
  data() {
    return {
      lastvalueStart1: "",
      valueStart1: "",
      valueStart2: "请选择",
      FHAddress: [],
      SHAddress: [],
      ZZAddress: [],
      stringValue: false,
      CarrierAmount: 30.0,
      AdditionalCost: 0.0,
      OrderAmount: 0.0,
      OrdersPKGS: 1,
      OrdersWeight: "",
      OrdersVolumn: "",
      PreDeliverDate: "", //计划发货日期
      PreArrivalDate: "", //计划到货日期
      Memo: "",
      // goods: [],
      showLoad: false,
      showServer: false,
      picJson: {
        imgLista: [],
        imgListBase: []
      },
      btnshow: true,
      showSecure: false,
      moneyNum: "",
      today: "",
      SterilizeTime: null,
      showDialogSecure: false,
      showDialogServer: false,
      showRule: true,
      type: "",
      remarkValue: [],
      remarkCheck: [],
      isSelectAddress: true,
      stationAddressValue: [],
      addressData: [],
      stationShow: false,
      stationValue: false,
      Balance: 0,
      transAddress: [],

      //---判断VIP等级设置保费
      secureMin: 0,
      secureValue: 0,
      secureFee: 0,
      InsuranceInstruct: "",
      GiveInsuranceFee: 0,
      IsDaytime:'Y',
      //---End
    };
  },
  watch: {
    //保费转换计算，规则是1万元：8元
    secureValue(val) {
      this.secureFee =this.secureValue == this.secureMin ? 0 : (this.secureValue - this.secureMin) * 8;
    },
    stringValue(val){
      // if (val) {
      //   this.GetFreight();
      // }else{
      //    this.GetFreight();
      // }
      this.GetFreight();
    },

    //中转开关监听逻辑
    stationValue(val) {
      if (val == false) { //如果是关闭操作
        if (this.Testlength(this.ZZAddress) > 0 && this.ZZAddress != null) { //检查当前的中转地址数据组是否有值
          this.ZZAddress = [];//如果有将地址组置空
          if (sessionStorage.ZZAddress && sessionStorage.ZZAddress != "") { ///检查SESSIONSTORAGE中的中转地址数据组是否有值
            sessionStorage.removeItem("ZZAddress"); //如果有则清除中转地址数据组
          }
          this.GetFreight(); //计算运费
        }
      } //如果是开启操作
      if (this.Testlength(this.ZZAddress) > 0 && this.ZZAddress != null) { //检查中转地址数据组是否有值
        this.GetFreight(); //如果有则计算运费
      }
    },

    //到达时间数据监听逻辑
    valueStart2(curVal, oldVal) {
      if (curVal != "请选择" && oldVal != "请选择") { //如果不是初始状态的值
        var self = this;

        //IOS下的时间处理方法
        var u = navigator.userAgent;
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        if (isiOS) {
          curVal = curVal.replace(/-/g, "/");
          oldVal = oldVal.replace(/-/g, "/");
        }
        //End

        var selectedArrivalTime = new Date(curVal + ":00"); //当前选择的到达时间
        var ExpectAttivalTime = new Date(
          selectedArrivalTime.getFullYear() +
            "-" +
            (selectedArrivalTime.getMonth() + 1) +
            "-" +
            selectedArrivalTime.getDate() +
            " " +
            this.SterilizeTime + //将时/分数具体换成消毒时间
            ":00"
        ); //转换时间值为带消毒时间值的标准格式

        //IOS下的时间处理方法
        if (isiOS) {
          ExpectAttivalTime = new Date(
            selectedArrivalTime.getFullYear() +
              "/" +
              (selectedArrivalTime.getMonth() + 1) +
              "/" +
              selectedArrivalTime.getDate() +
              " " +
              this.SterilizeTime +
              ":00"
          );
        }
        //End

        var oldTime = new Date(oldVal + ":00"); //获取前一次的时间数据
        var ts1 = Math.round(selectedArrivalTime.getTime()); //获取选定时间的时间戳
        var ts2 = Math.round(ExpectAttivalTime.getTime()); //获取替换过消毒时间的到达时间戳
        var ts3 = Math.round(oldTime.getTime()); //获取前一次选择的时间戳

        if (this.SterilizeTime) { //如果有消毒时间
          if (ts1 > ts2) { //选定的时间大于消毒时间
            self.$vux.confirm.show({
              title: "提示",
              content: "要求到达时间晚于消毒截止时间，确认吗？",
              onConfirm() {
                //确认时不作任何操作
              },
              onCancel() {
                var m = ExpectAttivalTime.getMonth() + 1;
                var day = ExpectAttivalTime.getDate();
                if (m < 9) {
                  m = "0" + m;
                }
                if (day < 9) {
                  day = "0" + day;
                }
                self.valueStart2 =
                  ExpectAttivalTime.getFullYear() +
                  "-" +
                  m +
                  "-" +
                  day +
                  " " +
                  self.SterilizeTime; //取消时换成符合消毒时间的
              }
            });
          }
        }
      }
      this.GetFreight(); //计算运费
    },
    remarkValue(val) {
      var arr = new Array(val);
      this.Memo = arr.join(",");
    }
  },
  created() {
    this.addressData = this.ChinaAddressV3Data;
    this.getData();
    this.getToday();
    this.getMomeTag();
  },
  computed: {
    userinfo() {
      if (localStorage.UserInfo) {
        return JSON.parse(localStorage.UserInfo);
      }
    }
  },
  methods: {
    BlurWeight() {
      var self = this;
      var val = self.OrdersWeight;
      var fhadd = self.FHAddress.Venue;
      var shadd = self.SHAddress.Venue;
      var origin = fhadd.replace(/\//g, "") + self.FHAddress.Address;
      var destinat = shadd.replace(/\//g, "") + self.SHAddress.Address;
      var AreaType = "1";
      //中转地
      if (self.stationValue) {
        if (self.Testlength(self.ZZAddress) > 0 && self.ZZAddress != null) {
          destinat =
            self.ZZAddress.Venue.replace(/\//g, "") + self.ZZAddress.Address;
        } else {
          if (self.SHAddress.City != self.FHAddress.City) {
            AreaType = "2";
          }
        }
      } else {
        if (self.SHAddress.City != self.FHAddress.City) {
          AreaType = "2";
        }
      }
      var coefficient =self.getSerivceTime();
      var UrgentCoefficient =1;
       if (self.stringValue) {
        UrgentCoefficient = self.userinfo.UrgentCoefficient;
      }
      var query = {
        TenantGuid: self.userinfo.TenantGuid,
        AreaType: AreaType,
        weight: val,
        standardWeigth: 20,
        origin: origin,
        destinat: destinat,
         coefficient:coefficient,
         UrgentCoefficient:UrgentCoefficient
      };

      this.$vux.loading.show({ transition: "", text: "运费计算中..." });

      this.Ajax.post("GetFreight", query).then(function(resp) {
        if (resp && resp.IsSuccess) {
          self.CarrierAmount = resp.Data.CarrierAmount.toFixed(2);
          self.AdditionalCost = resp.Data.AdditionalCost.toFixed(2);
          self.OrderAmount = resp.Data.OrderAmount.toFixed(2);
        };
        self.$vux.loading.hide();
      });
    },
    
    getSerivceTime() {
      var self = this;
      var UserLevel = self.userinfo.UserLevel;
      var serviceStartTime =self.userinfo.serviceStartTime;
      if (serviceStartTime.length==4) {
        serviceStartTime = '0'+serviceStartTime;
      }
      var serviceEndTime = self.userinfo.serviceEndTime;
        var setFormat = function(x) {
          if (x < 10) {
            x = "0" + x;
          }
          return x;
        };
        var valueStart2 = new Date((self.valueStart2 + ":00").replace(new RegExp(/-/gm) ,"/")); //当前选择的到达时间
        var time =new Date((valueStart2.getFullYear() +"/"+ (valueStart2.getMonth() + 1) +"/"+valueStart2.getDate()+" " +serviceEndTime+":00").replace(new RegExp(/-/gm) ,"/"));
        var timestart=new Date((valueStart2.getFullYear() +"/"+ (valueStart2.getMonth() + 1) +"/"+valueStart2.getDate()+" " +serviceStartTime+":00").replace(new RegExp(/-/gm) ,"/"));
   
        var ts1 = Math.round(valueStart2.getTime()); //获取选定时间的时间戳
        var ts2 = Math.round(time.getTime()); //获取替换过消毒时间的到达时间戳
        var ts3 = Math.round(timestart.getTime()); //获取前一次选择的时间戳
        if (self.valueStart2=='请选择') {
           return 1;
        }         
        if (ts1 < ts3 || ts1 > ts2) {
          self.IsDaytime='N';
          return self.userinfo.coefficient;

        } else {
          return 1;
      }
            
      // if (self.valueStart2 < timestart || self.valueStart2 > time) {
      //   return self.userinfo.coefficient;
      // } else {
      //   return 1;
      // }
    },

    GetFreight() {
      var self = this;
      self.showLoad = true;
      if (self.Testlength(self.FHAddress) == 0 || self.FHAddress == null) {
        self.showLoad = false;
        return false;
      }
      if (self.Testlength(self.SHAddress) == 0 || self.SHAddress == null) {
        self.showLoad = false;
        return false;
      }

      var fhadd = self.FHAddress.Venue;
      var shadd = self.SHAddress.Venue;
      var origin = fhadd.replace(/\//g, "") + self.FHAddress.Address;
      var destinat = shadd.replace(/\//g, "") + self.SHAddress.Address;
      var AreaType = "1";
      if (self.stationValue) {
        //中转地
        if (self.Testlength(self.ZZAddress) > 0 && self.ZZAddress != null) {
          destinat =
            self.ZZAddress.Venue.replace(/\//g, "") + self.ZZAddress.Address;
        } else {
          if (self.SHAddress.City != self.FHAddress.City) {
            AreaType = "2";
          }
        }
      } else {
        if (self.SHAddress.City != self.FHAddress.City) {
          AreaType = "2";
        }
      }
    
      var coefficient =self.getSerivceTime();
      var UrgentCoefficient =1;
      if (self.stringValue) {
        UrgentCoefficient = self.userinfo.UrgentCoefficient;
      }
      var query = {
        TenantGuid: self.userinfo.TenantGuid,
        AreaType: AreaType,
        weight: self.OrdersWeight,
        standardWeigth: 20,
        origin: origin,
        destinat: destinat,
        coefficient:coefficient,
        UrgentCoefficient:UrgentCoefficient
      };

      this.Ajax.post("GetFreight", query).then(function(resp) {
        if (resp && resp.IsSuccess) {
          self.showLoad = false;
          self.CarrierAmount = resp.Data.CarrierAmount.toFixed(2);
          self.AdditionalCost = resp.Data.AdditionalCost.toFixed(2);
          self.OrderAmount = resp.Data.OrderAmount.toFixed(2);
        }else{
          self.showLoad = false;
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: resp.ErrorMessage
        });
        }
      });
    },
    checkNum(val, txt) {
      var regTest = /^\d{1,8}(\.\d{0,3})?$/;
      if (!val) {
        this.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "请输入" + txt
        });
        return false;
      }
      if (!regTest.test(val) && val) {
        this.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: txt + "最多输入小数点后三位"
        });
        return false;
      }
      return true;
    },
    toFixedAmount(val, txt) {
      var regTest = /^\d{1,8}(\.\d{0,2})?$/;
      if (!regTest.test(val) && val) {
        this.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: txt + "最多只能输入小数点后两位"
        });
        return false;
      } else {
        return true;
      }
    },
    getMomeTag() {
      var self = this;
      var query = {
        TypeValue: "MomeTag"
      };
      this.Ajax.post("GetMomeTag", query).then(function(resp) {
        if (resp.IsSuccess) {
          resp.Datas.forEach(element => {
            var text = { text: element.DataIntroduction };
            self.remarkCheck.push(text);
          });
        }
      });
    },
    getToday() {
      var self = this;
      var setFormat = function(x) {
        if (x < 10) {
          x = "0" + x;
        }
        return x;
      };
      var date = new Date(),
          year = date.getFullYear(),
          month = date.getMonth(),
          day = date.getDate(),
          time = year + "-" + setFormat(month + 1) + "-" + setFormat(day);
      this.today = time; //今天
      function afterNowtime() {
        var date = new Date(); //日期对象
        var picktime = self.userinfo.picktime;
        date.setTime(date.getTime() + 1000 * 60 * picktime);
        var now = "";
        now = date.getFullYear() + "-"; //读英文就行了
        now = now + setFormat(date.getMonth() + 1) + "-"; //取月的时候取的是当前月-1如果想取当前月+1就可以了
        now = now + setFormat(date.getDate()) + " ";
        now = now + setFormat(date.getHours()) + ":";
        now = now + setFormat(date.getMinutes());
        return now;
      }
      this.lastvalueStart1 = afterNowtime();
      this.valueStart1 = afterNowtime();
    },
    getEndDate(type) {
      var self = this;
      var val = self.SHAddress;
      var date = new Date();
      // var Sd = date.getFullYear()+"-" + (date.getMonth()+1) + "-" + date.getDate()+" " +date.getHours()+":" +date.getMinutes()
      if (val.SterilizeTime != null && val.SterilizeTime != "") {
        self.SterilizeTime = val.SterilizeTime;
        var m = date.getMonth() + 1;
        var day = date.getDate();
        m = m < 10 ? "0" + m : m;
        day = day < 10 ? "0" + day : day;
        var Sd =
          date.getFullYear() + "-" + m + "-" + day + " " + val.SterilizeTime;
      } else {
        self.SterilizeTime = null;
        Sd = "请选择";
      }
      if (type != 1) {
        self.valueStart2 = Sd;
      }
    },
    goBack() {
      this.$router.push({
        path: "/index"
      });
    },
    saveSecure() {
      this.showSecure = false;
      this.moneyNum = this.secureValue + "万";
    },
    secure() {
      this.showSecure = true;
    },
    // choice() {
    //   this.$router.push({
    //     path: "/choice"
    //   });
    // },
    address(type) {
      var self = this,
        txt;
      if (type == "1") {
        txt = "发货";
      } else if (type == "2") {
        txt = "收货";
      }
      if (!self.isSelectAddress) {
        this.$vux.toast.show({
          type: "text", //success, warn, cancel, text
          text: "回送订单" + txt + "地址不允许修改!"
        });
        return false;
      }
      var guid = this.$route.query.id;
      if (!guid) {
        this.$router.push({
          path: "/address",
          query: {
            type: type
          }
        });
      } else {
        var query = self.$route.query;
        query.type = type;
        this.$router.push({
          path: "/address",
          query: query
        });
      }
    },
    transaddress() {
      this.$router.push({
        path: "/transaddress",
        query: {
          id: this.$route.query.id,
          Billtype: this.$route.query.Billtype
        }
      });
    },

    getData() {
      var self = this,
        type = this.$route.query.Billtype,
        guid = this.$route.query.id;
        self.type = type;

      //---VIP对应保费设置
      if (self.userinfo.UserLevel > 0) {
        self.secureMin = 1;
        self.secureValue = 1;
        self.GiveInsuranceFee = 1;
        self.InsuranceInstruct = "已赠送1万元保额，可自费增加保额";
      } else {
        self.secureMin = 0;
        self.secureValue = 0;
        self.GiveInsuranceFee = 0;
        self.InsuranceInstruct = "点击此处购买";
      }
      //---End

      if (guid) {
        this.getOrder(guid, type);
      } else {
        this.getsessionStorage();
      }
    },

    getsessionStorage() {
      if (sessionStorage.FHAddress) {
        this.FHAddress = JSON.parse(sessionStorage.FHAddress);
        this.GetFreight();
      } else {
        this.getDefaultAddress(1);
      }

      if (sessionStorage.SHAddress) {
        this.SHAddress = JSON.parse(sessionStorage.SHAddress);
        if (
          this.SHAddress.SterilizeTime &&
          this.SHAddress.SterilizeTime != ""
        ) {
          this.getEndDate(2);
        }
        this.GetFreight();
      } else {
        this.getDefaultAddress(2);
      }

      if (sessionStorage.ZZAddress) {
        this.ZZAddress = JSON.parse(sessionStorage.ZZAddress);
        this.stationValue = true;
        this.GetFreight();
      }

      // if (sessionStorage.goods) {
      //   this.goods = JSON.parse(sessionStorage.goods);
      //   this.goods.forEach(g => {
      //     this.OrdersPKGS += g.PurchaserPoQty;
      //     this.OrdersWeight += 0;
      //     this.OrdersVolumn += 0;
      //   });
      // }
      if (
        this.FHAddress.City &&
        this.SHAddress.City &&
        this.FHAddress.City != this.SHAddress.City
      ) {
        this.stationAddressValue.push(
          this.SHAddress.Province,
          this.SHAddress.City,
          this.SHAddress.District
        );
        this.stationShow = true;
      }
    },

    getDefaultAddress(type) {
      var self = this;
      var query = {
        CreateUserId: self.userinfo.StaffID,
        IsChecked: "Y"
      };
      this.Ajax.post("SearchCustomerAddress", query).then(function(resp) {
        if (resp.IsSuccess) {
          if (type == 1) {
            var FHItem = resp.Datas.find(x => x.type == "1");
            if (FHItem) {
              self.FHAddress = FHItem;
            } else {
              self.FHAddress = [];
            }
            self.GetFreight();
          }
          if (type == 2) {
            var SHItem = resp.Datas.find(x => x.type == "2");
            if (SHItem) {
              self.SHAddress = SHItem;
            } else {
              self.SHAddress = [];
            }
            self.GetFreight();
          }
          self.getEndDate(2);

          if (
            self.FHAddress.City &&
            self.SHAddress.City &&
            self.FHAddress.City != self.SHAddress.City
          ) {
            self.stationAddressValue.push(
              self.SHAddress.Province,
              self.SHAddress.City,
              self.SHAddress.District
            );
            self.stationShow = true;
          }
        }
      });
    },

    getOrder(guid, type) {
      var self = this;

      self.showLoad = true;
      var query = {
        Guid: guid
      };
      this.Ajax.post("GetOrderDetail", query).then(function(resp) {
        self.showLoad = false;
        if (resp.IsSuccess) {
          var info = resp.Data;

          var SHAddress = {
            Province: info.Main.DepartureProvince,
            City: info.Main.DepartureCity,
            District: info.Main.DepartureDistrict,
            Address: info.Main.DepartureAddress,
            Contacts: info.Main.PickContacts,
            ContactsTel: info.Main.PickContactsTel,
            Venue: info.Main.DepartureVenue
          };

          var FHAddress = {
            Province: info.Main.ArrivalProvince,
            City: info.Main.ArrivalCity,
            District: info.Main.ArrivalDistrict,
            Address: info.Main.ArrivalAddress,
            Contacts: info.Main.SendContacts,
            ContactsTel: info.Main.SendContactsTel,
            Venue: info.Main.ArrivalVenue
          };

          //读取中转地信息 lxf-20180605
          var ZZAddress = {};
          if (info.Main.StartBusTerminal && info.Main.EndBusTerminal) {
            var ftp = self.$options.filters["TextProvince"],
                ftc = self.$options.filters["TextCity"],
                ftd = self.$options.filters["TextDistrict"],
                args = info.Main.StartBusTerminal.split("/");
            ZZAddress = {
              Province: ftp(args[0]),
              City: ftc(args[1]),
              District: ftd(args[2]),
              Address: args.length > 3 ? args[3] : "",
              Venue: args[0] + "/" + args[1] + "/" + args[2]
            };
          }
          if(!sessionStorage.ZZAddress && self.Testlength(ZZAddress) >0)
          {
            sessionStorage.ZZAddress = JSON.stringify(ZZAddress);
          }


          if (type == "2")
          {
            self.FHAddress = FHAddress;
            self.SHAddress = SHAddress;
            if (info.HandOver.HandoverPict && info.HandOver.HandoverPict != "") 
            {
              self.picJson.imgLista = JSON.parse(info.HandOver.HandoverPict);
            }
            else
            {
              self.picJson.imgLista = [];
            }
            self.isSelectAddress = false;
          }

          //修改订单
          if (type == "1") {
            self.FHAddress = SHAddress;
            self.SHAddress = FHAddress;
            if (!sessionStorage.ZZAddress && self.Testlength(ZZAddress) > 0 && sessionStorage.ZZdeleted != "Y") {
              sessionStorage.ZZdeleted = "Y";
            }
            // self.ZZAddress = ZZAddress;
            if (info.Bill.BillType=='B05') {
              self.stringValue=true;
            }
            document.title = "修改订单";
            self.valueStart1 = info.Main.CollectionTime.replace("T"," ").substr(0, info.Main.CollectionTime.length - 3);
            self.valueStart2 = info.Main.LastArrivalArrivedDate.replace("T"," ").substr(0, info.Main.LastArrivalArrivedDate.length - 3);
            self.Memo = info.Main.Memo;
            self.btnshow = false;

            if(info.Main.PictContentPkg == 'null')
            {
              self.picJson.imgLista = [];
            }
            else
            {
              self.picJson.imgLista = JSON.parse(info.Main.PictContentPkg);
              // console.log(self.picJson.imgLista);
            }
          }
          self.Memo = info.Main.Memo;
          self.CarrierAmount = info.Main.CarrierAmount;
          self.OrdersPKGS = info.Main.OrdersPKGS;
          self.OrdersWeight = info.Main.OrdersWeight;
          self.OrdersVolumn = info.Main.OrdersVolumn;
          self.secureValue = info.Main.InsuranceAmount;
          self.secureFee = info.Main.InsuranceFee;
          self.moneyNum = self.secureValue + "万";
        }
        if (sessionStorage.FHAddress) {
          self.FHAddress = JSON.parse(sessionStorage.FHAddress);
        }
        if (sessionStorage.SHAddress) {
          self.SHAddress = JSON.parse(sessionStorage.SHAddress);
        }
        if (sessionStorage.ZZAddress) {
          self.ZZAddress = JSON.parse(sessionStorage.ZZAddress);
        }
        if (
          self.FHAddress.City &&
          self.SHAddress.City &&
          self.FHAddress.City != self.SHAddress.City
        ) {
          self.stationAddressValue.push(
            self.SHAddress.Province,
            self.SHAddress.City,
            self.SHAddress.District
          );
          self.stationShow = true;

          if (self.Testlength(self.ZZAddress) > 0) {
            self.stationValue = true;
          }
        }
        self.getEndDate(1);
        self.GetFreight();
      });
    },

    //获取账户余额
    getBalance(state) {
      var self = this,
        query = {
          BelongGuid: self.userinfo.BelongGuid
        };
      this.Ajax.post("GetBalance", query).then(function(resp) {
        self.Balance = resp.Data.Balance;
        // console.log(self.Balance);
        self.submit(state);
      });
    },

    submit(state) {
      var self = this,
          imglist = [],
          androidlist = [];

      for(var i = 0; i < self.picJson.imgLista.length; i++)
      {
          var item = self.picJson.imgLista[i];
          if(item.indexOf('base64') > -1)
          {
              if (window.__wxjs_is_wkwebview) {
                  var imgbase64 = item.substr(item.indexOf("base64") + 7, item.length);
                  item = imgbase64;
              }
          }
          imglist.push(item);
      }

      if (navigator.userAgent.indexOf("Android") > -1)
      {
          for(var k = 0; k < imglist.length; k++)
          {
              if(imglist[k].indexOf('File') > -1)
              {
                  androidlist.push(imglist[k]);
              }
          }
          androidlist = androidlist.concat(self.picJson.imgListBase);
          imglist = androidlist;
      }

      // for(var i = 0; i < imglist.length; i++)
      // {
      //     alert('imglist###' + i + '=======>' + JSON.stringify(imglist[i]))
      // }


      // if (imglist.length == 0) {
      //    self.$vux.toast.show({
      //     type: "warn", //success, warn, cancel, text
      //     text: "请上传装箱图片！"
      //   });
      //   return false;
      // }

      if (!self.FHAddress || self.FHAddress.length < 1) {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "请选择发货地址"
        });
        return false;
      }
      if (!self.SHAddress || self.SHAddress.length < 1) {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "请选择收货地址"
        });
        return false;
      }

      //处理IOS时间
      var lvs = self.lastvalueStart1.replace(new RegExp(/-/gm) ,"/");
      var vs = self.valueStart1.replace(new RegExp(/-/gm) ,"/");
      //---------End

      if (lvs > vs) {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "配送员最快需"+self.userinfo.picktime+"分钟内到达"
        });
        return false;
      }
      if (self.valueStart2 == "请选择") {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "请选择要求到达时间"
        });
        return false;
      }
      if (self.valueStart2 < self.valueStart1) {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "要求到达时间要大于提货时间。"
        });
        return false;
      }
      if (!self.OrdersPKGS) {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "请输入件数"
        });
        return false;
      };
      if (!this.checkNum(this.OrdersWeight, "重量")) {
        return false;
      }
      if (!this.checkNum(this.OrdersVolumn, "体积")) {
        return false;
      }

      var BillType = "B01";
      if (self.stringValue) {
        BillType = "B05";
      }

      //地区判断
      if (this.userinfo.TenantGuid != "20180515102052060001") {
        if (
          self.SHAddress.Province != "530000" ||
          self.FHAddress.Province != "530000"
        ) {
          self.$vux.toast.show({
            type: "warn", //success, warn, cancel, text
            text: "暂时只支持云南地区下单，其他地区暂未开放"
          });
          return false;
        }
      }

      //客运站判断
      if (this.stationValue) {
        if (self.Testlength(self.ZZAddress) == 0 || self.ZZAddress == null) {
          self.$vux.toast.show({
            type: "warn", //success, warn, cancel, text
            text: "中转交货地址没有填写"
          });
          return false;
        }

        if (self.stationAddressValue.length == 0) {
          self.$vux.toast.show({
            type: "warn", //success, warn, cancel, text
            text: "购票目的地没有选择"
          });
          return false;
        }
      }

      //余额判断
      if (1 * self.CarrierAmount + 1 * self.secureFee > self.Balance) {
        self.$vux.toast.show({
          type: "warn", //success, warn, cancel, text
          text: "账户余额不足，请联系运营人员充值",
          time: 3000,
          isShowMask: true,
          onHide() {
            self.$router.push({
              path: "/index"
            });
          }
        });
        return false;
      }
      //平台收益/配送员收益
      var PlatformAmount = self.OrderAmount;
      var DriverAmount = self.AdditionalCost;
   
      //构造Pomain
      var pomian = {
        TenantGuid: self.userinfo.TenantGuid, //租户GUID
        CorpGuid: self.userinfo.BelongGuid, //货主GUID
        CorpName: self.userinfo.BelongName, //货主名称
        DepartureProvince: self.FHAddress.Province, //发货地-省
        DepartureCity: self.FHAddress.City, //发货地-市
        DepartureDistrict: self.FHAddress.District, //发货地-区
        DepartureAddress: self.FHAddress.Address, //发货地-详细地址
        PickContacts: self.FHAddress.Contacts, //发货人
        PickContactsTel: self.FHAddress.ContactsTel, //发货人电话
        ArrivalProvince: self.SHAddress.Province, //目的地-省
        ArrivalCity: self.SHAddress.City, //目的地-市
        ArrivalDistrict: self.SHAddress.District, //目的地-区
        ArrivalAddress: self.SHAddress.Address, //目的地-详细地址
        SendContacts: self.SHAddress.Contacts, //收货人
        SendContactsTel: self.SHAddress.ContactsTel, //收货人电话
        Collectiontime: self.valueStart1, //要求提货时间
        LastArrivalArrivedDate: self.valueStart2, //要求达到时间
        CarrierAmount: self.CarrierAmount, //运费
        Memo: self.Memo, //备注
        OrdersPKGS: self.OrdersPKGS, //订单件数
        OrdersWeight: self.OrdersWeight, //订单重量
        OrdersVolumn: self.OrdersVolumn, //订单体积
        LoginedStaffID: self.userinfo.StaffID, //当前登录人的guid
        LoginedName: self.userinfo.Name, //当前登录人姓名
        // GoodsList: self.goods,
        ImgUrlList: imglist,
        // ImgUrlList: self.picJson.imgListBase, //待上传的装箱图片
        // ImgUrlOrgList: self.picJson.imgLista, //已上传的装箱图片
        State: state, //订单状态
        BillType: BillType, //订单类型（加急/普通）
        InsuranceAmount: self.secureValue, //保险额度
        InsuranceFee: self.secureFee, //保险费用
        Sendtype: self.type, //发送类型（正常/回送）
        SendGuid: self.$route.query.id, //回送GUID
        FHAddressGuid: self.FHAddress.Guid, //发货地信息GUID
        SHAddressGuid: self.SHAddress.Guid, //收货地信息GUID
        DepartureVenue: document.getElementById("DepartureVenue").innerHTML, //起始地省市区中文
        ArrivalVenue: document.getElementById("ArrivalVenue").innerHTML, //目的地省市区中文
        PlatformIncome: PlatformAmount, //平台收入
        DistributionIncome: DriverAmount, //配送员收入
        IsDaytime:self.IsDaytime,
      };

      //如果有中转信息，则开始获取中转数据并填充到待提交的数据
      if (this.stationValue) {
        pomian.ZZAddressGuid = self.ZZAddress.Guid; //中转地GUID
        pomian.StartBusTerminal = document.getElementById("StartBusTerminal").innerHTML; //起始客运站信息
        pomian.EndBusTerminal = document.getElementById("EndBusTerminal").innerHTML; //目的地客运站信息
      }

      var methods, txt;
      if (state == "1") //修改订单
      {
        methods = "EditOrder";
        pomian.BillGuid = this.$route.query.id;
        txt = "修改";
        submit(methods, pomian, txt);
      }
      else if (state == "11") //保存订单
      {
        methods = "PlaceOrder";
        txt = "保存";
        submit(methods, pomian, txt);
      }
      else //直接发单
      {
        methods = "PlaceOrder";
        txt = "发单";
        var txt2 = "，订单按时调配中！";
        var msg = "本次订单费用：<br/>" +
                  "运费 " + this.CarrierAmount + "元<br/>" +
                  "保险 " + this.secureFee + " 元<br/>" +
                  "增值服务 0元<br/>" +
                  "总计" + (1 * this.CarrierAmount + 1 * this.secureFee) + "元，确认下单吗？";
        this.$vux.confirm.show({
          title: "提示",
          content: msg,
          onConfirm() {
            submit(methods, pomian, txt, txt2); //点击确认发单时候调用提交方法
          },
          onCancel() {
            self.showLoad = false;
          }
        });
      }

      //提交方法 methods=接口名称， pomian=提交的数据， txt=基础提示语， txt2=发单提示语
      function submit(methods, pomian, txt, txt2) {
      self.showLoad = true;
        // console.log(pomian);
        txt2 = txt2 || ""; //提示语
        self.Ajax.post(methods, pomian).then(function(resp) {
          self.showLoad = false;
          if (resp.IsSuccess) {
            self.$vux.toast.show({
              type: "success", //success, warn, cancel, text
              text: txt + "成功" + txt2,
              time: 3000,
              isShowMask: true,
              onHide() {
                sessionStorage.clear();
                self.$router.push({
                  path: "/index"
                });
              }
            });
          } else {
            self.$vux.toast.show({
              type: "warn", //success, warn, cancel, text
              text: txt + "失败",
              time: 3000,
              isShowMask: true,
              onHide() {
                sessionStorage.removeItem("ZZdeleted");
              }
            });
          }
        });
      }
    },
    //对象类型数据进行length检测
    Testlength(obj) {
      return Object.keys(obj).length;
    }
  }
};
</script>